// 1.ES5通过构造函数实现类
function Phone(brand, price) {
  this.brand = brand;
  this.price = price;
}

// 在原型对象上添加方法(重用)
Phone.prototype.call = function () {
  console.log("我可以打电话");
}

// 实例化对象
const Huawei = new Phone("华为", 5999);
Huawei.call();
console.log(Huawei);


// 2.ES6方式实现
class Phone2 {
  constructor(brand, price) {
    this.brand = brand;
    this.price = price;
  }

  call() {
    console.log("我可以打电话");
  }
}

const onePlus = new Phone2("一加", 8999);
onePlus.call();
console.log(onePlus);